package cn.tx.customer;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/10/4 10:03
 */
@Component
public class FanoutCustomer {
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("work1"),
            exchange = @Exchange(name = "logs", type = "fanout")
    ))
    public void receive1(String message) {
        System.out.println("第三种：消费者【1】接收到message = " + message);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("work2"), //创建临时队列
            exchange = @Exchange(name = "logs", type = "fanout")
            //绑定交换机类型
    ))
    public void receive2(String message) {
        System.out.println("第三种：消费者【2】接收到message = " + message);
    }
}
